[Contract] Build Insurance Policy Lifecycle#494
Merged
truthixify merged 2 commits intoDistinctCodes:mainfrom Feb 22, 2026
Merged
[Contract] Build Insurance Policy Lifecycle#494truthixify merged 2 commits intoDistinctCodes:mainfrom
truthixify merged 2 commits intoDistinctCodes:mainfrom
Conversation
Enhance execute_detokenization() to fully eliminate tokens from circulation and clear all tokenization records: - Remove all token holder balances - Clear token locks for all holders - Remove unclaimed dividends - Delete token holders list - Remove transfer restrictions and whitelist - Clear token metadata - Remove TokenizedAsset record (eliminates all tokens) - Clear voting records before removal Add comprehensive tests: - test_token_elimination_on_execution: Verifies complete token removal - test_cannot_propose_after_execution: Ensures no re-proposals after execution Fixes DistinctCodes#473 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Complete implementation of on-chain insurance policy management for tokenized assets: Policy Management Functions: - create_policy(): Create policies with date validation and asset indexing - cancel_policy(): Cancel policy (holder or insurer authorized) - suspend_policy(): Suspend policy (insurer only) - expire_policy(): Expire policy (permissionless, requires end_date passed) - renew_policy(): Renew policy (insurer only) - get_policy(): Retrieve individual policy details - get_asset_policies(): Get all policies for an asset Data Structure: - InsurancePolicy with policy_type (Liability, Property, Comprehensive, Custom) - PolicyStatus: Active, Suspended, Expired, Cancelled - Coverage amount, deductible, premium tracking - Start/end timestamps with validation - Auto-renewal flag and last payment tracking Features: - Date validation (start_date < end_date, not in past) - Status transition validation (valid state transitions only) - Asset index maintains all policy IDs per asset - Authorization checks (holder/insurer for cancel, insurer for suspend/renew) - Permissionless expiration when end_date passes Comprehensive test suite (14 tests): - Policy creation with validation - Cancellation by holder and insurer - Suspension (authorized and unauthorized) - Expiration (before and after end_date) - Renewal of active and expired policies - Asset policy index - Status transition validation All 55 contract tests passing. Fixes DistinctCodes#474 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
@Josue19-08 is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a complete on-chain insurance policy management system for tokenized assets as specified in #474.
Changes
Data Structure
InsurancePolicystruct with all required fields:Liability,Property,Comprehensive,CustomActive,Suspended,Expired,CancelledCore Functions
create_policy()- Creates policies with comprehensive validation:cancel_policy()- Holder or insurer authorizedsuspend_policy()- Insurer onlyexpire_policy()- Permissionless, requiresend_date < current timestamprenew_policy()- Insurer onlyget_policy()- Retrieves individual policy detailsget_asset_policies()- Gets all policies for an assetFeatures
Acceptance Criteria Met
Tests Added (14 new tests)
test_create_policy_success- Valid policy creationtest_create_policy_invalid_dates- Date validationtest_create_policy_invalid_coverage- Coverage validationtest_cancel_policy_by_holder- Holder can canceltest_cancel_policy_by_insurer- Insurer can canceltest_cancel_policy_unauthorized- Unauthorized cannot canceltest_suspend_policy- Insurer can suspendtest_suspend_policy_unauthorized- Only insurer can suspendtest_expire_policy_before_end_date- Cannot expire earlytest_expire_policy_after_end_date- Can expire after end_datetest_renew_policy- Renew active policytest_renew_expired_policy- Renew expired policytest_get_asset_policies- Asset index workstest_status_transition_validation- Valid state transitionsAll 55 contract tests passing (41 existing + 14 new)
Related Issue
Closes #474
🤖 Generated with Claude Code